local heng__yuyan = fk.CreateSkill{
  name = "heng__yuyan",
}

Fk:loadTranslationTable{
  ["heng__yuyan"] = "预言",
  [":heng__yuyan"] = "出牌阶段限一次，你可以弃置一张牌，视为使用一张存活角色技能中包含的单目标普通锦囊牌。",

  ["#heng__yuyan"] = "预言：你可以弃置一张牌，视为使用一张场上角色技能中包含的单目标普通锦囊牌",
}

heng__yuyan:addEffect("viewas", {
  prompt = "#heng__yuyan",
  interaction = function(self, player)
    local all_names = {}
    for _, card in pairs(Fk.all_card_types) do
      if card:isCommonTrick()
        and not Fk:cloneCard(card.name).multiple_targets
        and not Fk:cloneCard(card.name).is_passive
        and not table.contains(all_names, card.name) then
        for _, p in ipairs(Fk:currentRoom().alive_players) do
          for _, s in ipairs(p:getSkillNameList()) do
            local desc = Fk:translate(":"..s, "zh_CN")
            if string.find(desc, Fk:translate(card.name, "zh_CN")[1].."【"..Fk:translate(card.trueName, "zh_CN").."】")
              or string.find(desc, "【"..Fk:translate(card.name, "zh_CN").."】") then
              table.insert(all_names, card.name)
            end
          end
        end
      end
    end
    local names = {}
    for _, name in ipairs(all_names) do
      local card = Fk:cloneCard(name)
      card.skillName = heng__yuyan.name
      if player:canUse(card) and not player:prohibitUse(card) then
        table.insert(names, name)
      end
    end
    return UI.CardNameBox { choices = names, all_choices = all_names }
  end,
  card_filter = Util.FalseFunc,
  view_as = function(self, player, cards)
    if self.interaction.data == nil then return end
    local card = Fk:cloneCard(self.interaction.data)
    card.skillName = heng__yuyan.name
    return card
  end,
  before_use = function(self, player, use)
    local room = player.room
    room:askToDiscard(player, {
        skill_name = heng__yuyan.name,
        min_num = 1,
        max_num = 1,
        include_equip = true,
        cancelable = false,
    })
  end,
  enabled_at_play = function(self, player)
    return player:usedEffectTimes(self.name, Player.HistoryPhase) == 0
    and not player:isNude()
  end,
})

return heng__yuyan